From 4af66f418b6837b6441b4e8eaf2d8ede585238b9 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Mon, 11 Aug 2025 11:51:39 +0100 Subject: snapshot --- frontend/app/drive/[...path]/page.tsx | 136 ++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 frontend/app/drive/[...path]/page.tsx (limited to 'frontend/app/drive/[...path]') diff --git a/frontend/app/drive/[...path]/page.tsx b/frontend/app/drive/[...path]/page.tsx new file mode 100644 index 0000000..75a1bb1 --- /dev/null +++ b/frontend/app/drive/[...path]/page.tsx @@ -0,0 +1,136 @@ +import { Drive_ls, Drive_basename, Drive_parent } from "@/lib/drive" +import { formatSize } from "@/lib/utils" +import Link from "next/link" +import { cookies } from 'next/headers'; +import { Auth_get_user } from "@/lib/auth"; + +interface DrivePageProps { + params: Promise<{ + path: string[] + }> +} + +export default async function DrivePage({ params }: DrivePageProps) { + // Await params as required by Next.js 15 + const { path } = await params + + const user = await Auth_get_user(); + console.log(user); + + // Construct the full path from params + const fullPath = path ? `/${path.join('/')}` : "" + + const entries = await Drive_ls(fullPath, false) + + // Check if we have a parent directory + const parentDir = Drive_parent(fullPath) + const parentPath = path && path.length > 1 + ? `/drive/${path.slice(0, -1).join('/')}` + : path && path.length === 1 + ? '/drive' + : null + + // Create entries with optional parent directory at top + const allEntries = [] + if (parentDir !== null && parentPath !== null) { + allEntries.push({ + path: '(parent)', + type: 'dir' as const, + lastmod: 0, + blob: null, + size: null, + author: '', + isParent: true, + parentPath + }) + } + + // Sort entries: directories first, then files, both alphabetically + const sortedEntries = entries.sort((a, b) => { + // First sort by type (directories before files) + if (a.type !== b.type) { + return a.type === 'dir' ? -1 : 1 + } + // Then sort alphabetically by path + return a.path.localeCompare(b.path) + }) + + allEntries.push(...sortedEntries) + + return ( +
+
+ +

FCTDrive

+ + +
+
+ + + + + + + + + + + {allEntries.map((entry, index) => ( + + + + + + + ))} + +
+ Name + + Size + + Author + + Modified +
+
+
+ {entry.type === 'dir' ? ( +
📁
+ ) : ( +
📄
+ )} +
+ {entry.type === 'dir' ? ( + + {(entry as any).isParent ? '(parent)' : Drive_basename(entry.path)} + + ) : ( + + {Drive_basename(entry.path)} + + )} +
+
+ {formatSize(entry.size)} + + {entry.author} + + {new Date(entry.lastmod * 1000).toLocaleString()} +
+
+
+
+
+ ) +} -- cgit